package leetcode.editor.cn;

public class P523 {
    public static void main(String[] args) {

    }
    public boolean checkSubarraySum(int[] nums, int k) {
        int[] sums = new int[nums.length + 1];
        for (int i = 0; i < nums.length; i++) {
            sums[i + 1] = sums[i] + nums[i];
        }
        for (int i = 1; i <= nums.length; i++) {
            for (int j = 0; j < i; j++) {
                int sum = sums[i] - sums[j];
                if (sum % k == 0 && sum != 0) {
                    return true;
                }
            }
        }
        return false;
    }
}
